try {
	Type.registerNamespace('NCMMDBDetailUtil');
	NCMMDBDetailUtil.apptablename;
	NCMMDBDetailUtil.pageIndex = NaN;
	NCMMDBDetailUtil.pageSize = 50;
	NCMMDBDetailUtil.groupInfo;

	//显示详情页标题
	NCMMDBDetailUtil.showTitle = function(param) {
		var doctitle = param["appbillname"];
		$ctx.put("doctitle", doctitle);
		$ctx.dataBind();
	};

	//本地表中是否有数据
	NCMMDBDetailUtil.isNeedShow = function(param) {
		if(param["downloadnum"] == null || param["downloadnum"] == "" || param["downloadnum"] == "0") {
			return false;
		} else {
			return true;
		}
	};

	//查询本地表数据显示在列表中
	NCMMDBDetailUtil.showDataList = function(wheresql) {
		var VOClass = NCMMDBUtil.getDataVOByTablename(NCMMDBDetailUtil.apptablename);
		NCMMDBDetailUtil.groupInfo = NCMMDBDetailUtil.getGroups(VOClass, wheresql);
		NCMMDBDetailUtil.pageIndex = parseInt(0);

		NCMMDBDetailUtil.showDataFromLocalTable2017(VOClass, wheresql);
	};

	//获得分组信息
	NCMMDBDetailUtil.getGroups = function(VOClass, wheresql) {
		var rowsum = NCMMPubUtil.queryVOCount(VOClass, wheresql, null);
		if(rowsum == null || rowsum < 0)
			return null;
		else
			return NCMMDBUtil.getGroup(rowsum, NCMMDBDetailUtil.pageSize);
	};

	//显示当前组中数据
	NCMMDBDetailUtil.showDataFromLocalTable = function(VOClass, wheresql) {
		NCMMPubUtil.queryVO(VOClass, wheresql, function(data) {
//				$alert("after data=" + JSON.stringify(data));
				$ctx.put("bdlistdata", data);
				$ctx.dataBind();
				if(NCMMDBDetailUtil.groupInfo)
					$toast("第" + (NCMMDBDetailUtil.pageIndex + 1) + "页/共" + (NCMMDBDetailUtil.groupInfo.length).toString() + "页");
			},
			NCMMDBDetailUtil.pageIndex, NCMMDBDetailUtil.pageSize);
	};
	
		NCMMDBDetailUtil.showDataFromLocalTable2017 = function(VOClass, wheresql) {
		NCMMPubUtil.queryVO(VOClass, wheresql, function(data) {
				data = NCMMPubUtil.htmlspecialjsonarray2UI(data);				
				$ctx.put("bdlistdata", data);
//				$alert("after ctx=" + $ctx.getString("bdlistdata"));
				$ctx.dataBind();

				if(NCMMDBDetailUtil.groupInfo)
					$toast("第" + (NCMMDBDetailUtil.pageIndex + 1) + "页/共" + (NCMMDBDetailUtil.groupInfo.length).toString() + "页");
			},
			NCMMDBDetailUtil.pageIndex, NCMMDBDetailUtil.pageSize);
	};

	//列表上划数据
	NCMMDBDetailUtil.listUp = function(wheresql) {
		if(NCMMDBDetailUtil.pageIndex == 0) {
			$toast("没有更多数据");
			return false;
		}

		var VOClass = NCMMDBUtil.getDataVOByTablename(NCMMDBDetailUtil.apptablename);
		NCMMDBDetailUtil.pageIndex = NCMMDBDetailUtil.pageIndex - 1;
		NCMMDBDetailUtil.showDataFromLocalTable2017(VOClass, wheresql);
		return true;
	};

	//列表下拉数据
	NCMMDBDetailUtil.listDown = function(wheresql) {
		if(NCMMDBDetailUtil.groupInfo == null || (NCMMDBDetailUtil.pageIndex + 1) == (NCMMDBDetailUtil.groupInfo).length) {
			$toast("没有更多数据");
			return false;
		}

		var VOClass = NCMMDBUtil.getDataVOByTablename(NCMMDBDetailUtil.apptablename);
		NCMMDBDetailUtil.pageIndex = NCMMDBDetailUtil.pageIndex + 1;
		NCMMDBDetailUtil.showDataFromLocalTable2017(VOClass, wheresql);
		return true;
	};

} catch(e) {
	$e(e);
}